import { http } from './request.js'

export const walletAPI = {
    // 查询钱包余额
    getBalance: (userId) => http.secure.get('/wallet/balance', { userId }),

    // 充值
    recharge: (data) => http.secure.post('/wallet/recharge', data),

    // 提现
    withdraw: (data) => http.secure.post('/wallet/withdraw', data),

    // 冻结资金
    freeze: (data) => http.secure.post('/wallet/freeze', data),

    // 解冻资金
    unfreeze: (data) => http.secure.post('/wallet/unfreeze', data),

    // 支付
    payment: (data) => http.secure.post('/payment/pay', data),

    // 还款
    repay: (data) => http.secure.post('/wallet/overdraft/repay', data),

    // 确认收货
    confirmReceipt: (data) => http.secure.post('/payment/confirm', data),

    // 退款
    refund: (data) => http.secure.post('/payment/refund', data),

    // 查询交易流水
    getTransactions: (walletId, page = 0, size = 10) =>
        http.secure.get('/transaction/list', { walletId, page, size }),

    // 按类型查询交易
    getTransactionsByType: (walletId, type, page = 0, size = 10) =>
        http.secure.get('/transaction/list/by-type', { walletId, type, page, size }),

    // 按时间范围查询交易
    getTransactionsByTimeRange: (walletId, startTime, endTime, page = 0, size = 10) =>
        http.secure.get('/transaction/list/by-time', { walletId, startTime, endTime, page, size })
}
